home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / scroll / scroll.frm < prev    next >
Text File  |  1995-12-05  |  4KB  |  142 lines

  1. VERSION 2.00
  2. Begin Form ScrollDemo 
  3.    Caption         =   "Scrolling Demo"
  4.    ClientHeight    =   5205
  5.    ClientLeft      =   1215
  6.    ClientTop       =   1545
  7.    ClientWidth     =   7170
  8.    Height          =   5610
  9.    Icon            =   0
  10.    Left            =   1155
  11.    LinkMode        =   1  'Source
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   5205
  14.    ScaleWidth      =   7170
  15.    Top             =   1200
  16.    Width           =   7290
  17.    Begin HScrollBar HScroll1 
  18.       Height          =   300
  19.       Left            =   0
  20.       TabIndex        =   1
  21.       Top             =   4920
  22.       Width           =   6885
  23.    End
  24.    Begin VScrollBar VScroll1 
  25.       Height          =   4935
  26.       Left            =   6870
  27.       TabIndex        =   0
  28.       Top             =   0
  29.       Width           =   300
  30.    End
  31.    Begin PictureBox Picture1 
  32.       BackColor       =   &H00C0C0C0&
  33.       BorderStyle     =   0  'None
  34.       ForeColor       =   &H00000000&
  35.       Height          =   4935
  36.       Left            =   0
  37.       ScaleHeight     =   329
  38.       ScaleMode       =   3  'Pixel
  39.       ScaleWidth      =   459
  40.       TabIndex        =   2
  41.       Top             =   0
  42.       Width           =   6885
  43.       Begin PictureBox picture2 
  44.          AutoSize        =   -1  'True
  45.          BackColor       =   &H000000FF&
  46.          BorderStyle     =   0  'None
  47.          Height          =   7200
  48.          Left            =   0
  49.          Picture         =   SCROLL.FRX:0000
  50.          ScaleHeight     =   480
  51.          ScaleMode       =   3  'Pixel
  52.          ScaleWidth      =   640
  53.          TabIndex        =   3
  54.          Top             =   0
  55.          Width           =   9600
  56.          Begin CommandButton Command4 
  57.             Caption         =   "Command4"
  58.             Height          =   345
  59.             Left            =   7140
  60.             TabIndex        =   7
  61.             Top             =   6600
  62.             Width           =   1575
  63.          End
  64.          Begin CommandButton Command1 
  65.             Caption         =   "Command1"
  66.             Height          =   435
  67.             Left            =   5160
  68.             TabIndex        =   4
  69.             Top             =   4440
  70.             Width           =   1305
  71.          End
  72.          Begin CommandButton Command3 
  73.             Caption         =   "Command3"
  74.             Height          =   405
  75.             Left            =   8310
  76.             TabIndex        =   6
  77.             Top             =   2880
  78.             Width           =   975
  79.          End
  80.          Begin CommandButton Command2 
  81.             Caption         =   "Command2"
  82.             Height          =   345
  83.             Left            =   990
  84.             TabIndex        =   5
  85.             Top             =   960
  86.             Width           =   1545
  87.          End
  88.       End
  89.    End
  90. End
  91.  
  92. Sub Form_Resize ()
  93.  
  94.   ' Repostioin scrollbars and parent picture control
  95.   VScroll1.Move ScaleWidth - VScroll1.Width, 0, VScroll1.Width, ScaleHeight - HScroll1.Height
  96.   HScroll1.Move 0, ScaleHeight - HScroll1.Height, ScaleWidth - VScroll1.Width
  97.   Picture1.Move 0, 0, VScroll1.Left, HScroll1.Top
  98.  
  99.   ' Enable or Disable VScroll1 depending on new size of Form
  100.   VScroll1.Value = 0  'Generates VScroll1_Change() event
  101.   VDiff = Picture1.ScaleHeight - Picture2.Height
  102.   VScroll1.Enabled = VDiff <= 0
  103.   If VScroll1.Enabled Then
  104.       VScroll1.Max = Abs(VDiff)
  105.       VScroll1.LargeChange = VScroll1.Max \ 10
  106.   End If
  107.   
  108.   ' Enable or Disable HScroll1 depending on new size of Form
  109.   HScroll1.Value = 0
  110.   HDiff = Picture1.ScaleWidth - Picture2.Width
  111.   HScroll1.Enabled = HDiff <= 0
  112.   If HScroll1.Enabled Then
  113.       HScroll1.Max = Abs(HDiff)
  114.       HScroll1.LargeChange = HScroll1.Max \ 10
  115.   End If
  116.  
  117. End Sub
  118.  
  119. Sub HScroll1_Change ()
  120.  
  121.   ' Picture.Left is set to the Negative of the value since
  122.   ' as you scroll the Scrollbar to the Right, the display
  123.   ' should move to the Left, showing more of the right
  124.   ' of the display, and vice-versa when scrolling to the
  125.   ' left
  126.  
  127.   Picture2.Left = -HScroll1.Value
  128.  
  129. End Sub
  130.  
  131. Sub VScroll1_Change ()
  132.   
  133.   ' Picture.Top is set to the Negative of the value since
  134.   ' as you scroll the Scrollbar down, the display
  135.   ' should move up, showing more of the the bottom
  136.   ' of the display, and vice-versa when scrolling up
  137.   
  138.   Picture2.Top = -VScroll1.Value
  139.   
  140. End Sub
  141.  
  142.